package org.duanyu.shopping_goods_service.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.duanyu.shopping_common.pojo.Goods;
import org.duanyu.shopping_common.pojo.GoodsDesc;

import java.util.List;

@Mapper
public interface GoodsMapper extends BaseMapper<Goods> {
    //添加商品规格项id
    @Insert("insert into bz_goods_specification_option values (#{gid},#{optionId})")
    void addGoodsSpecificationOption(@Param("gid") Long gid,@Param("optionId") Long optionId);

    //删除商品下的所有的详情
    @Delete("delete from bz_goods_specification_option where gid=#{gid}")
    void deleteGoodsSpecificationOption(Long gid);

    //商品的上下架
    @Update("update bz_goods set isMarketable=#{isMarketable} where id=#{id}")
    void putAway(@Param("id") Long id,@Param("isMarketable") boolean isMarketable);

    Goods findById(Long id);

    /**
     * 查询所有商品详情
     * @return 返回商品详情
     */
    List<GoodsDesc> findAll();

    //查询商品详情
    GoodsDesc findDesc(Long id);


}
